<?php

/**
* @current blog.php
* @author   LiuYang <liu_yang@haibao.com>
* @date 2016年4月27日 下午3:50:20
*/

namespace haibao\user\data;

class Blog extends \haibao\user\data\BaseMysql {
    
    public function __construct() {
        parent::__construct ( '\haibao\user\model\data\Blog' );
        $this->setConfig( \haibao\classlibrary\www\Config::CLASSLIBRARY_CONFIG_MYSQL_HAIBAO_DZ3 );
    }
    
    public function getBlogProperty($userId,$isMySelf){
        $sql='SELECT blogid,uid,SUM(viewnum_false) AS ViewNum, SUM(replynum) AS ReplyNum,SUM(favtimes) AS FavTimes FROM hb_home_blog WHERE uid=%s';
        if(!$isMySelf){
            $sql .= ' AND status='.\haibao\user\model\data\Blog::STATUS_SUCCESS;
        }
        
        $result = $this->query($sql,array($userId));
        
        $temp = array();
        
        while ($row = $result->fetch_assoc()){
            $temp= $row;
        }
       
        return $temp;
    }
}
